package com.dragon.app.other;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @Author: longtao
 * @Date: 2019/9/17
 * @Version: 1.0
 * @Description:
 */
public class T6 {


    @Test
    public void t() {

        int[] ints = twoSum(new int[]{2, 7, 11, 15}, 27);
        System.out.println(Arrays.toString(ints));




    }


    public int[] twoSum(int[] nums, int target) {
        int[] ints = new int[2];
        for (int i = 0; i < nums.length - 1; i++) {
            ints[0] = i;
            for(int j=i+1;j<nums.length;j++){
                if(nums[i]+nums[j]==target){
                    ints[1]=j;
                    return ints;
                }
            }
        }
        return null;
    }


}
